package czk.concrent.threadpool.newSingleThreadexecutor;

import java.util.concurrent.*;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/30 23:23
 */
public class TestSubmit {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(2);
        Future<String> submit = executorService.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                TimeUnit.SECONDS.sleep(2);
                return "ok";
            }
        });
        // 阻塞方法，底层是保护性暂停的实现
        String s = submit.get();
        System.out.println(s);
    }
}
